using System.Collections.Generic;
using System.Security;

namespace Be.Timvw.Framework.Security
{
    /// <summary>
    /// This class providers methods that should simplify interaction with SecureString
    /// </summary>
    public static class SecureStringHelper
    {
        /// <summary>
        /// Creates a readonly securestring from the given characters.
        /// </summary>
        /// <param name="characters"></param>
        /// <returns></returns>
        public static SecureString Create(IEnumerable<char> characters)
        {
            SecureString secureString = new SecureString();
            foreach(char c in characters)
            {
                secureString.AppendChar(c);
            }

            secureString.MakeReadOnly();
            return secureString;
        }
    }
}